package day06

import java.text.SimpleDateFormat

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.SparkSession

object aa {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setAppName("AA").setMaster("local[2]")
    val sc = new SparkContext(conf)
    val data: RDD[String] = sc.textFile("C:\\Users\\fuhao\\Desktop\\a.txt ")


    val sdf = new SimpleDateFormat("HH:mm:ss")
    val data2: RDD[(Int, Long, String)] = data.map(x => {
      val va: Array[String] = x.split("\t")
      val id: Int = va(0).toInt
      val date: Long = sdf.parse(va(1)).getTime
      val url: String = va(2)
      (id, date, url)
    }).sortBy(_._1)
    val data3: RDD[(Int, String, String)] = data2.map(x => {
      val date: String = sdf.format(x._2)
      (x._1, date, x._3)
    })


    print(data3.collect().toBuffer)

  }
}
